// 创建sessionStorage监听
var orignalSetItem = sessionStorage.setItem;
sessionStorage.setItem = function (key, newValue) {
  var setItemEvent = new Event("setItemEvent");
  setItemEvent.newValue = newValue;
  setItemEvent.key = key;
  window.dispatchEvent(setItemEvent);
  orignalSetItem.apply(this, arguments);
}
// 监听返回数据 跳转告警
window.addEventListener("setItemEvent", function (e) {
  if (e.key === 'MainwtDirectReq') {
    let type = JSON.parse(e.newValue).Direct
    switch (type) {
      case 'MainwtIndexReq':
        window.location.hash = 'home'
        break
      case 'MainwtViolationReq':
        window.location.hash = 'alarm?type=MainwtViolationReq'
        break
      case 'MainwtSuspectReq':
        window.location.hash = 'alarm?type=MainwtSuspectReq'
        break
      case 'MainwtDeleteReq':
        window.location.hash = 'alarm?type=MainwtDeleteReq'
        break
      case 'MainwtMessageReq':
        window.location.hash = 'message'
        break
    }
  }
})